<template>
	<ynet-content id="operateMain" :headerInformation="true" :headerMenu="true">
        <div class="main-container">
			<ynet-breadcrumb></ynet-breadcrumb>
		</div>
		<div class="main-container lrb pt10" v-if="main">
            <div>
                <el-form ref="queryForm" :model="queryForm" class="formEmbedTable mt20" :rules="rules" >
                    <table>
                        <caption>Enquiry</caption>
                        <tr>
                            <td>TBS No.</td>
                            <td>
                                <el-form-item prop="TBSNo">
                                    <el-input v-model="queryForm.TBSNo"  ></el-input>
                                </el-form-item>
                            </td>				
                        </tr>
                    </table>
				</el-form>
			</div>
            <div class="btnArea mt20 tac">
                <el-button type="primary" @click="queryOperate">Search</el-button>
                <el-button type="primary" @click="resetForm('queryForm')">Reset</el-button>
            </div>

            <div>
				<el-form ref="custForm" :model="custForm" class="formEmbedTable mt20" >
					<table>
						<tr>
							<td style="text-align:center;background: #aca2a0;color: #fff;font-weight:bold;font-family: Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB, Microsoft YaHei, SimSun, sans-serif;">Customer Name</td>
							<td>
								<el-form-item prop="CustomerName">
									<el-input v-model="custForm.CustomerName" ></el-input>
								</el-form-item>
							</td>
						</tr>
					</table>
				</el-form>
			</div>

            <div class="fourForm tableForm tableData">
                <el-table :data="TBStranlist"  >
                    <el-table-column prop="trantype" label="Transation Type" align="center">
                    </el-table-column>
                    <el-table-column prop="fromAC" label="From A/C" align="center"></el-table-column>
                    <el-table-column prop="ACtype" label="A/C Type" align="center"></el-table-column>
                    <el-table-column prop="ToAC" label="To A/C" align="center"></el-table-column>
                    <el-table-column prop="TranCcy" label="Transation Ccy" align="center">
                    </el-table-column>
                    <el-table-column prop="TBSAmount" label="Amount" align="center">
                    </el-table-column>
                    <el-table-column prop="tranTime" label="Transation Date Time" align="center">
                    </el-table-column>
                    <el-table-column prop="tranSeqNo" label="Transation Sequence No." align="center">
                    </el-table-column>
                </el-table>
            </div>
            <!-- 分页组件 -->
            <!--分页-->
            <div class="pagination tar mt20">
                <el-pagination  @current-change="handleCurrentChange" :current-page="Number(queryForm.currentPage)" :page-size="Number(queryForm.turnPageShowNum)" layout="total, prev, pager, next, jumper" :total="Number(turnPageTotalNum)">
            </el-pagination>
            </div>
            <!--分页--END-->
          
            
		</div>
        <!--授权确认页面弹窗-->
        <div>
            <ynet-authDialog ref="dialogTable"  @getAuthForm="getAuthForm"></ynet-authDialog>
        </div>
        <!--<div class="main-container">
            <OperateAdd v-if="isAdd" @back="backMain"></OperateAdd>
            <OperDetail v-if="isDetail" :operInfoDetail="operInfoDetail" @back="backMain"></OperDetail>
            <OperateEdit v-if="isEdit" :operInfoDetail="operInfoDetail" @back="backMain"></OperateEdit>
        </div>-->
	</ynet-content>
</template>

<script>
	/*import OperateAdd from './components/operateAdd';
    import OperDetail from './components/operDetail';
    import OperateEdit from './components/operateEdit';*/
	export default {
		name:'operateMain',
		components:{
		},
		data(){
            return { 
                turnPageTotalNum:'',
                queryForm:{
                    TBSNo:'',CustomerName:'',currentPage:'1',turnPageShowNum:'10'
                },
                custForm:{
                    CustomerName:'',
                },
                rules:{
                    TBSNo: [
                    { required: true, message: '电话银行账号不能为空', trigger: 'blur' },
                    // { min: 6, max: 20, message: '用户名长度在6到20位', trigger: 'blur' },
                    { validator: this.$tools.validator.isInteger, trigger: 'blur' },
                    ],
                    /*CustomerName: [
                    { required: true, message: '', trigger: 'blur' },
                    ],*/
                },
                tableData:[],
                isAdd:false,isDetail:false,isEdit:false,main:true,
                TBStranlist:[],//从后台查询的操作员信息数组
                operInfoDetail:{},
                selectData:[],
                rePwd:{actionFlag:'1',bsnCode:'IM0105',imUserInfoList:[],},
                delForm:{stt:'3',actionType:'2',imUserInfoList:[],bsnCode:'IM0103',},
                actionType:[],//删除还是重置密码
                dialogTableVisible:false,
                authForm: { authUserNo: '', password: '',randomField:''},//授权数据
                needAuth:'',
                authType:'',
            }
            
        },
		methods:{
            backMain(){
                this.selectData=[];
                this.operInfoDetail={};
                this.queryOperate();
                this.main=true;
                this.isAdd=false;
                this.isDetail=false;
                this.isEdit=false;
            },
            getAuthForm(val){
                //获取授权数据
                this.authForm=val;
                console.log("val:"+JSON.stringify(val))
                this.delForm=$.extend({},this.delForm,this.authForm)
                this.delOper()  //自己页面提交给后台的.do方法
            },
            queryAuth(formName){//查询授权模式
                if(this.selectData.length!=0){
                    let body={};body.bsnCode="IM0103";body.version="IM0103",
                    this.$tools.request(this,"IM010001Action.do",body).then(data=>{
                        //console.log("authData:"+JSON.stringify(data))
                        if(data.body.errorCode==0){
                            if(data.body.needAuth==0){//无需授权
                                this.delOper()
                            }else if(data.body.needAuth==1 && data.body.authType==1){
                                this.needAuth=1;
                                this.authType=1;
                                this.$refs["dialogTable"].show()
                            }else if( data.body.needAuth==1 && data.body.authType==2 ){
                                this.needAuth=1;
                                this.authType=2;
                                this.delOper()
                            }else{
                                this.$alert('授权类型异常,请检查', '温馨提示', {
                                    confirmButtonText: 'Confirm',
                                    callback: action => {
                                    }
                                });
                            }
                        }else{
                            this.$alert("System Error Try again", "warning",{
                                confirmButtonText: 'Confirm',
                                callback: action => {
                                }
                            })
                        }
                        
                    })
                }else{
                    this.$alert('请选择数据', '温馨提示', {
                        confirmButtonText: 'Confirm',
                        callback: action => {
                        }
                    });
                }
			},
            delOper(){//删除操作员
                this.delForm.imUserInfoList=this.selectData;
                //console.log("delForm:"+JSON.stringify(this.delForm))
                this.$tools.request(this,"IM010302Action.do",this.delForm).then(data=>{
                    //console.log("data:"+JSON.stringify(data))
                    if(data.body.errorCode==0){
                        if(this.needAuth==1 && this.authType==2){
                            this.$alert('提交成功,等待授权', '温馨提示', {
                                confirmButtonText: 'Confirm',
                                callback: action => {
                                    this.queryOperate()
                                }
                            });
                        }else{
                            this.$alert("修改成功","提示",{
                                confirmButtonText: 'Confirm',
                                callback: action => {
                                    this.queryOperate()
                                }
                            })
                        }
                    }else{
                        this.$alert("System Error Try again", "warning",{
                            confirmButtonText: 'Confirm',
                            callback: action => {
                            }
                        })
                    }
                })
            },
            
            resetForm(formName){//清空
                this.$refs[formName].resetFields();
                 this.tableData=[];
            },
            openDetail(val){
                //点击客户号显示详情
                for(let i=0;i<this.TBStranlist.length;i++){
                    if(this.TBStranlist[i].userNo==val){
                        this.operInfoDetail=this.TBStranlist[i];
                        break;
                    }
                }
                this.main=false;
                this.isDetail=true;
            },
            queryOperate(){
            	if(this.queryForm.TBSNo ==''){
            		return;
            	}

            	this.$refs.queryForm.validate((valid)=>{
            		if(valid){
            		this.$tools.request(this,"IM0403.do",this.queryForm).then(data=>{
                    if(data.body.errorCode==0){
                    	//console.log("返回后台数据："+data.body.TBSNo)
                        this.TBStranlist=data.body.TBStranlist;
                        this.turnPageTotalNum=data.body.turnPageTotalNum;
                        this.custForm.CustomerName = data.body.CustomerName;
                       // console.log("TBSNO后台数据："+data.body.TBSNo);
                    }else{
                        this.$alert("System Error Try again", "warning",{
                            confirmButtonText: 'Confirm',
                            callback: action => {
                            }
                        })
                    }
                })	
            		}
            	})
               
            },
            operateAdd(){
                this.isAdd=true;
                this.main=false;
                this.isEdit=false;
                this.isDetail=false;
            },
            operEdit(){
                if(this.selectData.length!=1){
                    this.$alert("请选择修改项","温馨提示",{
                        confirmButtonText: 'Confirm',
                        callback: action => {
                        }
                    })
                }else{
                    this.operInfoDetail=this.selectData[0];
                    this.main=false;
                    this.isAdd=false;
                    this.isEdit=true;
                }
            },
            handleSelectChange(val){
                this.selectData=val;
            },
            cleanOther() {
				let _this = this
				_this.$refs.queryForm.resetFields()
			},
            handleCurrentChange(val) {//分页方法
                this.queryForm.currentPage=val;
                this.queryOperate()
            },
		}
	}
</script>